<template>
    <div>
        <a-modal
            :title="fromState.modelTitle"
            :visible="visible"
            @ok="handleOk"
            @cancel="cancel(false)"
            :width="fromState.width?fromState.width:800"
            :dialog-style="{top:40+'px'}"
        >
            <modalPageSupervisor
             ref="modalPageSupervisorRef" 
             v-if="fromState.modelType=='modalPageSupervisor'" 
             @successChange="successChange" 
             @cancel="cancel" />

            <candidate
             ref="candidateRef" 
             v-if="fromState.modelType=='candidate'" 
             @successChange="successChange" 
             @cancel="cancel" />

             <editorInspector
             ref="editorInspectorRef" 
             v-if="fromState.modelType=='editorInspector'" 
             @successChange="successChange" 
             @cancel="cancel"
             />
        </a-modal>
    </div>
</template>
<script>
import modalPageSupervisor from './modalPage/supervisor.vue'
import candidate from './modalPage/candidate.vue'
import editorInspector from './modalPage/editorInspector.vue'
export default {
    components:{
        modalPageSupervisor,
        candidate,
        editorInspector,
    },
    props:{

    },
    data(){
        return{
            visible:false,
            fromState:{},
        }
    },
    watch:{

    },
    mounted(){
        
    },
    methods:{
        getData(val){
            this.fromState = val
            this.$nextTick(()=>{
                this.$refs[val.modelType+'Ref'].getData(val)
            })
        },
        handleOk(){
            //console.log(5555)
            if(this.$refs[this.fromState.modelType+'Ref'].handleOk){
                //console.log(5555)
                this.$refs[this.fromState.modelType+'Ref'].handleOk()
            }else{
                this.visible = false
            }
        },
        cancel(val){
            this.visible = val
        },
        successChange(val){
            this.$emit('successChange',val)
        },
        saveData(name,value){
            this.$emit('saveData',name,value)
            
        },
    }
}
</script>